package com.spark.lola.mapper.statistics;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spark.lola.statistics.entity.StatisticsCar;
import com.spark.lola.support.mybatis.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * @author: Zhi-peng wang
 * @date: 2020/05/14 13:49
 * 车辆货运总量统计信息mapper
 **/
@Mapper
public interface StatisticsCarMapper extends BaseMapper<StatisticsCar> {

    IPage<StatisticsCar> findPage(Page<StatisticsCar> page, @Param("groupType") Integer groupType, @Param(Constants.WRAPPER) Wrapper<StatisticsCar> wrapper);

    @Select("select * from statistics_car where car_id=#{carId} and create_date=#{createDate}")
    StatisticsCar findByCarIdAndCreateDate(long carId, Date createDate);

    @Select("select id from statistics_car where create_date=#{createDate}")
    List<Long> findHaveByCarIdAndCreateDate(Date createDate);

    @Delete("delete from statistics_car where find_in_set(id,#{ids})<>0")
    void deleteByIds(String ids);
}
